<template>
  <div class="order-detail">
    <van-nav-bar
        title="我的订单-支付"
        left-text="返回"
        left-arrow
        @click-left="$router.go(-1)"
    />
    <van-skeleton
        title
        :row="5"
        :loading="loading"
        class="skeleton_body">
      <div v-for="item in orderData" :key="item.id" class="tab_item">
        <div v-if="item.list.length > 0">
          <div class="top_body">
            <span>{{item.name}}</span>
            <span v-if="item.pay_status === 0" class="status_02">未支付</span>
            <span v-if="item.pay_status === 1" class="status_01">已支付</span>
          </div>
          <div class="content_body">
            <div class="p_item">
              <p>子账单号：{{item.order_bills_sn}}</p>
              <p>交易时间：{{item.create_time}}</p>
            </div>
            <div v-for="feeItem in item.list" :key="feeItem.fee_item_name" class="p_item">
              <p>{{feeItem.fee_item_name}}：<em>¥{{feeItem.price}}</em></p>
            </div>
          </div>
          <div class="footer_body">
            <span>总额：<em>¥{{item.pay_amount}}</em></span>
            <span>实付：<em>¥{{item.real_price}}</em></span>
            <a v-if="item.pay_status === 0" :href="item.pay_url">付款</a>
          </div>
        </div>
        <div v-else>
          <div class="top_body">
            <span>订单号：{{item.order_bills_sn}}</span>
            <span v-if="item.pay_status === 1" class="status_02">待付款</span>
            <span v-if="item.pay_status === 2" class="status_02">部分支付</span>
            <span v-if="item.pay_status === 3" class="status_01">已支付</span>
            <span v-if="item.pay_status === 4" class="status_01">申请退款</span>
            <span v-if="item.pay_status === 5" class="status_03">已退款</span>
            <span v-if="item.pay_status === 6" class="status_03">转专业</span>
            <span v-if="item.pay_status === 98" class="status_03">无效订单</span>
            <span v-if="item.pay_status === 99" class="status_03">已取消</span>
          </div>
          <div class="content_body">
            <div class="p_item">
              <p>{{item.name}}</p>
            </div>
            <div v-for="feeItem in item.list" :key="feeItem.fee_item_name" class="p_item">
              <p>{{feeItem.fee_item_name}}：<em>¥{{feeItem.price}}</em></p>
            </div>
          </div>
          <div class="footer_body">
            <span>总额：<em>¥{{item.pay_amount}}</em></span>
            <span>实付：<em>¥{{item.real_price}}</em></span>
            <a :href="item.pay_url">付款</a>
          </div>
        </div>
      </div>
      <div class="no_order" v-if="orderData.length === 0">
        <van-icon name="balance-list-o" />
        <P>没有订单详情</P>
      </div>
    </van-skeleton>
  </div>
</template>
<script>
export default {
  name: 'order-detail',
  components: {},
  data () {
    return {
      id: 0,
      loading: true,
      orderData: []
    }
  },
  props: {},
  watch: {},
  methods: {
    /*
     *@author wf_Huang
     *@Time 2019/7/18 0018 9:33
     *@function  获取订单详情
     *****************************************/
    getListDetail () {
      this.$http({
        url: `${window.SITE_CONFIG['personalURL']}/api/ajax.User/getOrderDetail?orderId=${this.id}`,
        method: 'get',
        withCredentials: false
      }).then(({ data: res }) => {
        if (res.status !== 200) {
          this.$toast('获取数据失败')
        }
        if (res.data) {
          this.orderData = res.data
          this.loading = false
        } else {
          this.loading = false
        }
      }).catch(() => {})
    }
  },
  computed: {},
  created () {
  },
  mounted () {
    document.querySelector('body').setAttribute('style', 'background-color:#f8f8f8')
    this.id = this.$route.query.id || 0
    this.getListDetail()
  },
  destroyed () {
    document.querySelector('body').removeAttribute('style')
  }
}
</script>
<style lang="scss" scoped>
  .order-detail {
    background-color: #f8f8f8;
    padding-bottom: 50px;
    .van-nav-bar .van-icon {
      color: #231916;
      vertical-align: middle;
    }
    .van-nav-bar__text {
      display: inline-block;
      margin: 0 -15px;
      padding: 0 15px;
      color: #231916;
      vertical-align: middle;
    }
    .skeleton_body{
      padding: 30px;
    }
    .no_order{
      font-size: 30px;
      color: #e6e6e6;
      text-align: center;
      padding: 300px 0;
      i{
        font-size: 160px;
      }
    }
    .tab_item{
      background-color: #ffffff;
      margin-top: 30px;
      .top_body{
        padding: 20px 40px;
        display: flex;
        justify-content: space-between;
        line-height: 40px;
        span{
          font-size: 28px;
          color: #222222;
          letter-spacing: 0;
        }
        .status_01{
          color: #027FFE;
        }
        .status_02{
          color: #FBA146;
        }
        .status_03{
          color: #999999;
        }
      }
      .content_body{
        border-bottom: 1px solid #E6E6E6;
        border-top: 1px solid #E6E6E6;
        .p_item{
          padding: 20px 40px;
          font-size: 28px;
          color: #222222;
          border-top: 1px solid #E6E6E6;
          margin-top: -1px;
          p{
            margin: 10px 0;
          }
          em{
            color: #FF0000;
            font-style: normal;
          }
        }
      }
      .footer_body{
        padding: 20px 40px;
        display: flex;
        flex-wrap: wrap;
        line-height: 60px;
        span{
          font-size: 28px;
          color: #222222;
          margin-right: 30px;
          font-weight: bold;
          &:nth-child(2){
            margin-right:auto
          }
          em{
            color: #FF0000;
            font-style: normal;
          }
        }
        a{
          background: #FA3A51;
          border-radius: 4px;
          font-size: 28px;
          color: #FFFFFF;
          width: 180px;
          line-height: 64px;
          text-align: center;
        }
      }
    }
  }
</style>
